import request from '@/config/axios'

// 话题 VO
export interface TopicInfoVO {
  id: number // 话题ID
  name: string // 话题名称
  description: string // 话题描述
  pic: string // 封面图片URL
  articleCount: number // 话题下的文章数量
  followCount: number // 话题关注数量
  sort: number // 排序，数值越大越靠前
  status: number // 状态：0-正常，1-禁用
  isRecommend: number // 是否推荐：0-否，1-是
  hotScore: number // 热度分数
}

// 话题 API
export const TopicInfoApi = {
  // 查询话题分页
  getTopicInfoPage: async (params: any) => {
    return await request.get({ url: `/promotion/topic-info/page`, params })
  },

  // 查询话题详情
  getTopicInfoById: async (id: number) => {
    return await request.get({ url: `/promotion/topic-info/getById?id=` + id })
  },

  // 新增话题
  createTopicInfo: async (data: TopicInfoVO) => {
    return await request.post({ url: `/promotion/topic-info/create`, data })
  },

  // 修改话题
  updateTopicInfo: async (data: TopicInfoVO) => {
    return await request.post({ url: `/promotion/topic-info/update`, data })
  },

  // 修改话题状态
  updateTopicInfoStatus: async (id: number, status: number) => {
    const data = {
      id,
      status
    }
    return await request.post({ url: `/promotion/topic-info/updateStatus`, data: data })
  },

  // 删除话题
  deleteTopicInfoById: async (id: number) => {
    return await request.get({ url: `/promotion/topic-info/delete?id=` + id })
  },

  // 导出话题 Excel
  exportTopicInfo: async (params) => {
    return await request.download({ url: `/promotion/topic-info/export-excel`, params })
  }
}